{template 'header'}
<ul class="we7-page-tab">
	<li class="active"><a href="{php echo $this->createWebUrl('permission', array('direct' => 1))}">商城访问权限</a></li>
</ul>
<div class="alert we7-page-alert blacklist-alert">
	<p class="color-red"> 请注意，白名单一旦开启，黑名单将自动关闭。 </p>
</div>
<div id="js-store-permission" ng-controller="storePermissionCtrl" ng-cloak>
	<div class="we7-form blacklist-tab">
		<input type="radio" id="1" ng-checked="type == 'black'">
		<label for="1" ng-click="changeType('black')">黑名单设置 <span ng-class="{'active': !permissionStatus.close && permissionStatus.blacklist}"></span></label>
		<input type="radio" id="2" ng-checked="type == 'white'">
		<label for="2" ng-click="changeType('white')">白名单设置<span ng-class="{'active': !permissionStatus.close && permissionStatus.whitelist}"></span></label>
		<input type="radio" id="3" ng-checked="type == 'close'">
		<label for="3" ng-click="changeType('close')">关闭权限设置<span ng-class="{'active': permissionStatus.close}"></span></label>
	</div>
	<div class="alert we7-page-alert blacklist-alert" ng-hide="type == 'close'">
		<div class="info" ng-show="type == 'black'">
			<p>黑名单开启关闭</p>
			<p class="color-default"><i class="wi wi-info-sign"></i><strong >将用户放入黑名单，用户登录就无权限进入“商城” </strong></p>
		</div>
		<div class="switch" ng-class="{'switchOn': !permissionStatus.close && permissionStatus.blacklist}" ng-show="type == 'black'" ng-click="changeStatus()"></div>

		<div class="info" ng-show="type == 'white'">
			<p>白名单开启关闭</p>
			<p class="color-default"><i class="wi wi-info-sign"></i><strong >将用户放入白名单，用户登录将有权限进入“商城” </strong></p>
		</div>
		<div class="switch" ng-class="{'switchOn': !permissionStatus.close && permissionStatus.whitelist}" ng-show="type == 'white'" ng-click="changeStatus()"></div>
	</div>
	<div class="we7-margin-bottom clearfix" ng-hide="type == 'close'">
		<div class="pull-right">
			<a href="#" class="btn btn-primary we7-padding-horizontal" data-toggle="modal" data-target="#balck" ng-show="type == 'black'">添加黑名单用户</a>
			<a href="#" class="btn btn-primary we7-padding-horizontal" data-toggle="modal" data-target="#balck" ng-show="type == 'white'">添加白名单用户</a>
		</div>
	</div>
	<table class="table we7-table table-hover site-list" ng-hide="type == 'close'">
		<col width=""/>
		<col width="90px"/>
		<tr>
			<th class="text-left">用户名</th>
			<th class="text-left">操作</th>
		</tr>
		<tr ng-repeat="list in blacklist" ng-show="blacklist && type == 'black'">
			<td class="vertical-middle">
				<span ng-bind="list"></span>
			</td>
			<td class="text-left">
				<div class="link-group text-left">
					<a href="javascript:;" ng-click="deleteUser(list)">删除</a>
				</div>
			</td>
		</tr>
		<tr ng-show="!blacklist && type == 'black'">
			<td colspan="2" class="text-center">暂无数据</td>
		</tr>
		<tr ng-repeat="list in whitelist" ng-show="whitelist && type == 'white'">
			<td class="vertical-middle">
				<span ng-bind="list"></span>
			</td>
			<td class="text-left">
				<div class="link-group text-left">
					<a href="javascript:;" ng-click="deleteUser(list)">删除</a>
				</div>
			</td>
		</tr>
		<tr ng-show="!whitelist && type == 'white'">
			<td colspan="2" class="text-center">暂无数据</td>
		</tr>
	</table>
	<div class="modal fade" id="balck" tabindex="-1" role="dialog">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" ng-show="type == 'black'">添加黑名单用户</h4>
					<h4 class="modal-title" ng-show="type == 'white'">添加白名单用户</h4>
				</div>
				<div class="modal-body we7-padding">
					<div class="form-group">
						<label class="control-label col-sm-2">用户名：</label>
						<div class="col-sm-8">
							<input type="text" ng-model="addUsername" class="form-control" placeholder="请填写用户名">
							<span class="help-block">输入用户名，点击确定即可。</span>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="submit" class="btn btn-primary" ng-click="addUser()">确定</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	angular.module('storeApp').value('config', {
		type: "{php echo !empty($_GPC['type']) ? $_GPC['type'] : 'black'}",
		blacklist : {php echo json_encode($blacklist)},
		whitelist : {php echo json_encode($whitelist)},
		permissionStatus: {php echo json_encode($permission_status)},
		links: {
			addUser: "{php echo $this->createWebUrl('permission', array('operation' => 'post', 'direct' =>1))}",
			deleteUser: "{php echo $this->createWebUrl('permission', array('operation' => 'delete', 'direct' =>1))}",
			changeStatus: "{php echo $this->createWebUrl('permission', array('operation' => 'change_status', 'direct' =>1))}",
		}
	});

	angular.bootstrap($('#js-store-permission'), ['storeApp']);
</script>
{template 'common/footer'}